import java.text.DecimalFormat;

public class Segment extends Polygons {
    /**
     * 
     */
    private Point x1;
    private Point x2;

    public double area() {
        return 0;
    }

    public double perimeter() {
        double perimeter = 2 * Math.sqrt((Math.pow((x2.getX() - x1.getX()), 2) + (Math.pow((x2.getY() - x1.getY()), 2))));
        return perimeter;
    }

    public Segment(Point p1, Point p2) {
        x1 = p1;
        x2 = p2;
    }

    
    public Point getCenter() {
        double x = (x1.getX() + x2.getX()) / 2;
        double y = (x2.getY() + x2.getY()) / 2;
        return new Point(x, y);
    }

    public String toString(){
        StringBuilder figureString=new StringBuilder();
        DecimalFormat f = new DecimalFormat(Figures.pattern);
       figureString.append("Point1:").append("x:").append(f.format(x1.getX())).append(" ").append("y:").append(f.format(x1.getY())).append(" ").append("Point2:").append("x:").append(f.format(x2.getX())).append(" ").append("y:").append(f.format(x2.getY())).append(" ");
       figureString.append("Perimeter:").append(f.format(this.perimeter())).append(" ").append("Area:").append(f.format(this.area())).append(" ").append("CenterX:").append(f.format(this.getCenter().getX())).append(" ").append("CenterY:").append(f.format(this.getCenter().getY()));;
       String segment = new String(figureString);
       return segment;
    }
}
